package cn.bigfire.wedesk.util;

import cn.bigfire.wedesk.bean.Wedesk;
import cn.bigfire.wedesk.store.Stores;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ScreenSendTimer {
    //调用一下为了初始化和开启定时任务
    public static void init(){

    }
    public static ExecutorService executor = Executors.newSingleThreadExecutor();

    static {
        executor.submit(() -> {
            while (true) {
                try {
                    ScreenData screenData = Stores.blockingQueue.take();
                    if (!screenData.isExpired()) {
                        PackUtil.sendImgData(screenData.getScreensHot());
                    } else {
                        System.err.println("过期图片长度:" + screenData.getScreensHot().getData().length);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }


}
